#include "ringdata.h"
#include "buffs.h"
#include "symbol.h"
#include "creature.h"
#include "message.h"

class UnidRingBuff : public UnidentifiedBuff {
public:

    virtual ~UnidRingBuff() { };

protected:

    virtual bool Name( std::string* name, bool* plural, uint article ) const
    {
        PRE_ACTOR;
        if ( name->empty() && article == ARTICLE_INDEFINITE )
            *name += "a ";
        if ( article == ARTICLE_PLURAL )
            *name += "rings";
        else
            *name += "ring";
        return false;
    }

    bool ItemSymbol( IO::Sym* symbol ) const
    {
        POST_ACTOR;
        symbol->second = Colour( 128, 128, 128 );
        return true;
    }

};

Ring::Ring()
{
    ( new UnidRingBuff() )->SetTarget( this );
}

bool Ring::ItemType( uint* type ) const
{
    *type |= WEARABLE_RING;
    return true;
}

bool Ring::ItemCategory( uint* category ) const
{
    *category = ACCESSORY;
    return true;
}

bool Ring::ItemSymbol( IO::Sym* symbol ) const
{
    symbol->first = 'o';
    return true;
}

bool Ring::ItemWeight( uint* weight ) const
{
    *weight += 1;
    return true;
}

bool Ring::OnEaten( Creature* c )
{
    Bank().Manipulation( MANIPULATION_EAT_RING, c, this );
    Destroy();
    return true;
}

bool Ring::OnEquip( bool wield )
{
    if ( GetActor()->IsPlayer() )
        Call< BIOnIdentify >();
    return true;
}

bool RingStr::Name( std::string* name, bool* plural, uint article ) const
{
    if ( name->empty() && article == ARTICLE_INDEFINITE )
        *name += "a ";
    if ( article == ARTICLE_PLURAL )
        *name += "rings of strength";
    else
        *name += "ring of strength";
    return true;
}

bool RingStr::ItemSymbol( IO::Sym* symbol ) const
{
    Ring::ItemSymbol( symbol );
    symbol->second = Colour( 192, 0, 0 );
    return true;
}

bool RingStr::CreateWearBuff( CompoundBuff** buff ) const
{
    ( *buff )->AddBuff( new StatsBuff( 0, 0, 1, 0, 0, 0, 0, 0 ) );
    return true;
}

bool RingDex::Name( std::string* name, bool* plural, uint article ) const
{
    if ( name->empty() && article == ARTICLE_INDEFINITE )
        *name += "a ";
    if ( article == ARTICLE_PLURAL )
        *name += "rings of dexterity";
    else
        *name += "ring of dexterity";
    return true;
}

bool RingDex::ItemSymbol( IO::Sym* symbol ) const
{
    Ring::ItemSymbol( symbol );
    symbol->second = Colour( 0, 192, 0 );
    return true;
}

bool RingDex::CreateWearBuff( CompoundBuff** buff ) const
{
    ( *buff )->AddBuff( new StatsBuff( 0, 0, 0, 1, 0, 0, 0, 0 ) );
    return true;
}

bool RingInt::Name( std::string* name, bool* plural, uint article ) const
{
    if ( name->empty() && article == ARTICLE_INDEFINITE )
        *name += "a ";
    if ( article == ARTICLE_PLURAL )
        *name += "rings of intelligence";
    else
        *name += "ring of intelligence";
    return true;
}

bool RingInt::ItemSymbol( IO::Sym* symbol ) const
{
    Ring::ItemSymbol( symbol );
    symbol->second = Colour( 0, 0, 192 );
    return true;
}

bool RingInt::CreateWearBuff( CompoundBuff** buff ) const
{
    ( *buff )->AddBuff( new StatsBuff( 0, 0, 0, 0, 1, 0, 0, 0 ) );
    return true;
}